/*
  This file is part of 'Trivial chess'.

  'Trivial chess' is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  'Trivial chess' is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with 'Trivial chess'.  If not, see <http://www.gnu.org/licenses/>.
*/

/* SVN FILE: $Id$ */
/**
 * @author         $Author$
 * @version        $Rev$
 * @lastrevision   $Date$
 * @filesource     $URL$
 */

#ifndef BOARDMENSQ_H_
#define BOARDMENSQ_H_

#include <boost/cstdint.hpp>
#include <boost/array.hpp>

#include "BoardMenAbstract.h"

template<class BoardMen, class Br, class Sq>
class BoardMenSq
	: public BoardMenAbstract<BoardMen,Br,Sq> {

public:
	typedef Sq Square;
private:

public:
	BoardMenSq<BoardMen,Br,Sq>()
		: square(Square::Iterator::end()) {}

	BoardMenSq<BoardMen,Br,Sq>(const Board& board)
		: square(Square::Iterator::begin()), board(&board) {


	}

	void increment() {
		do {
			++this->square;
		} while ( !this->me_c().predicate()
				&& this->square != Square::Iterator::end() );
	}

	bool equal(BoardMenSq const& other) const {
		return this->square == other.square;
	}

	const Square dereference() const {
		return *this->square;
	}

	bool predicate() const;

protected:
	typename Square::Iterator square;
	const Board* board;
};

#endif /* BOARDMENSQ_H_ */
